unit DebugFrm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ActnList, StdActns, StrUtils;

type
  TDebugForm = class(TForm)
    Memo: TMemo;
    ActionList: TActionList;
    EditSelectAll1: TEditSelectAll;
  private
    { Private declarations }
  public
    procedure Append(Str: String);
  end;

function DebugForm: TDebugForm;
procedure Log(Str: String);

implementation

{$R *.dfm}

var
  FDebugForm: TDebugForm=nil;


function DebugForm: TDebugForm;
begin
  if FDebugForm = nil then
  begin
    Application.CreateForm(TDebugForm, FDebugForm);
  end;
  result := FDebugForm;
end;

{ TDebugForm }

procedure TDebugForm.Append(Str: String);
begin
  Str := AnsiReplaceStr(Str, #10, #13#10);
  Str := AnsiReplaceStr(Str, #13#13, #13); // kui sai topelt, siis ...
  Memo.Lines.Add(FormatDateTime('c', Now));
  Memo.Lines.Add(Str);
  Memo.Lines.Add('------------------------------')
end;

procedure Log(Str: String);
begin
  DebugForm.Append(Str);
end;

end.
